package com.laomuji.android.mvvm.http.common

import com.laomuji.android.mvvm.utils.MyLog
import okhttp3.RequestBody
import okio.Buffer


/**
 * 一些Http公共的方法
 * @author laomuji666
 * @since 2024/2/20
 */
object CommonUtil {
    fun log(tag: String?, content: String?) {
        if (tag == null || content == null) {
            return
        }
        MyLog.iCustom(tag, content)
    }

    fun getBodyString(body: RequestBody?): String {
        if (body == null) {
            return ""
        }
        return try {
            val buffer = Buffer()
            body.writeTo(buffer)
            buffer.readUtf8()
        } catch (e: Exception) {
            ""
        }
    }
}